<?php
$company			= array('id'=>'bill_company', 'class'=>'span6 form-control', 'name'=>'company', 'value'=> set_value('company'));
$first				= array('id'=>'bill_firstname', 'class'=>'span3 form-control', 'name'=>'firstname', 'value'=> set_value('firstname'));
$other_infomation	= array('id'=>'bill_other_infomation', 'class'=>'span3 form-control', 'name'=>'other_infomation', 'value'=> set_value('other_infomation'));
$address			= array('id'=>'bill_address', 'class'=>'span3 form-control', 'name'=>'address', 'value'=> set_value('address'));
$last				= array('id'=>'bill_lastname', 'class'=>'span3 form-control', 'name'=>'lastname', 'value'=> set_value('lastname'));
$fullname			= array('id'=>'bill_fullname', 'class'=>'span3 form-control', 'name'=>'fullname', 'value'=> set_value('fullname'));
$email				= array('id'=>'bill_email', 'class'=>'span3 form-control', 'name'=>'email', 'value'=>set_value('email'));
$phone				= array('id'=>'bill_phone', 'class'=>'span3 form-control', 'name'=>'phone', 'value'=> set_value('phone'));
$birth				= array('id'=>'date_birth', 'class'=>'span3 form-control', 'name'=>'birth', 'value'=>set_value('birth'));
echo theme_css('jquery-ui.css', true);
echo theme_js('jquery-ui.js', true);
?>
<style>.checkbox-inline input{position:absolute;margin-left:-20px}</style>
<!------------------------- Content home --------------------------->
<div class="content_wp">
	<div class="container">
        	<div class="breadcrumb_wp">
            	<ol class="breadcrumb">
                  <li><a href="#">Trang Chủ</a></li>
                  <li class="active">Đăng ký</li>
                </ol>
            </div>
            <div class="gio_hang_wp">
            	
            	<div class="title_article">
                	<h3><i class="fa fa-shopping-cart"></i> Đăng ký</h3>
                </div>
                <h2 class="title_cart">Thông tin khách hàng dành cho đại lý</h2>
                <p>Vui lòng nhập các mục sau đây. Sau khi nhập, xin vui lòng nhấn vào nút đến trang xác nhận.</p>
				<p><span class="red">*</span> Yêu cầu bắt buộc nhập thông tin.</p>
                <div class="rege_new_member_wp form_register">
                	<?php $text_success = $this->session->flashdata('success'); if(!empty( $text_success)){?><div class="success"><?php echo  $text_success;?> </div><?php }?>
                	<div id="messager">
						<?php if(!empty($error_messger)){?>
                            <div class="alert alert-error">
                                <a class="close" data-dismiss="alert">×</a>
                                <?php echo $error_messger?>
                            </div>
                        <?php }?>
                    </div>
                    <?php if(!$this->session->flashdata('success')){?>
                	<?php $attributes = array("enctype"=>"multipart/form-data");echo form_open(LINK_FOR_AGENCY,$attributes); ?>
                    <input type="hidden" name="submitted" value="submitted" />
                    <input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />      
                       <div class="form-group">
                    	<label for="account_fullname"><?php echo lang('account_company');?> <span class="red">*</span></label>
						<?php echo form_input($company);?>
                        <div class="clear"></div>
					</div>                 
                    <div class="form-group">
                    	<label for="account_fullname">Họ và tên người đại điện công ty <span class="red">*</span></label>
						<?php echo form_input($fullname);?>
                        <div class="clear"></div>
					</div>
					<div class="form-group">
                    	<label for="account_fullname">Địa chỉ công ty: <span class="red">*</span></label>
						<?php echo form_input($address);?>
                        <div class="clear"></div>
					</div>
                    <div class="form-group">
						<label for="account_email"><?php echo lang('account_email');?>  (Dùng đăng nhập website) <span class="red">*</span></label>
						<?php echo form_input($email);?>
                         <div class="clear"></div>
                    </div>
					<div class="form-group">
						<label for="account_phone"><?php echo lang('account_phone');?> liên hệ<span class="red">*</span></label>
						<?php echo form_input($phone);?><div class="clear"></div>
                    </div>
                    <div class="form-group">
						<label for="account_password"><?php echo lang('account_password');?> <span class="red">*</span></label>
						<input cl type="password" name="password" value="" class="span3 form-control" autocomplete="off" />
                         <div class="clear"></div>
					</div>
					<div class="form-group">
						<label for="account_confirm"><?php echo lang('account_confirm');?> <span class="red">*</span></label>
						<input type="password" name="confirm" value="" class="span3 form-control" autocomplete="off" />
                         <div class="clear"></div>
					</div>
					<div class="form-group">
                    	<label for="account_fullname">Xin vui lòng cung cấp thêm về công ty của bạn (ngành nghề hoạt động, mặt hàng kinh doanh,...) <span class="red">*</span></label>
						<?php echo form_textarea($other_infomation);?>
                        <div class="clear"></div>
					</div>
                    <div class="form-group">
                    	<label for="account_fullname">Hình ảnh về công ty của bạn (3 hình) </label> <span class="red">*</span><br />
                        <p style="margin-top:20px"> <span style="float:left;margin-right:10px;font-weight:bold">Hình 1 </span><input id="file1" type="file" name="file1" /></p>
                        <p style="margin-top:20px"> <span style="float:left;margin-right:10px;font-weight:bold">Hình 2</span><input id="file2"  type="file" name="file2" /></p>
                        <p style="margin-top:20px"> <span style="float:left;margin-right:10px;font-weight:bold">Hình 3</span><input id="file3"  type="file" name="file3" /></p>
                    </div>
                    <div class="form-group">
						<input type="checkbox" name="email_subscribe" value="1" <?php echo set_radio('email_subscribe', '1', TRUE); ?>/> <?php echo lang('account_newsletter_subscribe');?>
					</div>
                     <input type="submit" value="<?php echo lang('form_register');?>" class="btn btn-primary" />
                </form>
                <?php }?>
                </div>
            </div>
        </div>
    </div>
</div>
<script language="javascript">
$("#date_birth").datepicker({
	dateFormat:"dd/mm/yy",	
	changeYear: true,
	changeMonth:true,
	monthNamesShort:[1,2,3,4,5,6,7,8,9,10,11,12],
	yearRange:"1975:-10",
});
$(".btn-primary").click(function(){
	var fullname 		  = $("input[name='fullname']").val();
	var company 		  = $("input[name='company']").val();

	var email 	  		  = $("input[name='email']").val();
	var phone 	  		  = $("input[name='phone']").val();
	var pass 	  		  = $("input[name='password']").val();
	var confirm_pass 	  = $("input[name='confirm']").val();
	
	var file1			  = $('#file1').val();
	var file3			  = $('#file3').val();
	var file2			  = $('#file2').val();

	var $html_error = "";
	if(company == null || company == "")
		$html_error += "<div><?php echo sprintf(lang("error_empty"),"tên công ty")?></div>";
	if(fullname == null || fullname == "")
		$html_error += "<div><?php echo lang("error_fullname_empty")?></div>";
	if(phone == null || phone == "")
		$html_error += "<div><?php echo lang("error_phone_empty")?></div>";
	if(email == null || email == "")
		$html_error += "<div><?php echo lang("error_email_empty")?></div>";
	else{
		regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if(!regex.test(email)) {
			$html_error += "<div><?php echo lang("error_email_type")?></div>";
		}
	}
	if(pass == null || pass == "")
		$html_error += "<div><?php echo lang("error_phone_empty")?></div>";
	else{
		if(pass != confirm_pass)	
		$html_error += "<div><?php echo lang("error_confirm_password")?></div>";
	}
	if(file1 == null || file1 == "")
		$html_error += "<div><?php echo sprintf(lang("error_empty"),"Hình ảnh 1")?></div>";
	if(file2 == null || file2 == "")
		$html_error += "<div><?php echo sprintf(lang("error_empty"),"Hình ảnh 2")?></div>";
	if(file3 == null || file3 == "")
		$html_error += "<div><?php echo sprintf(lang("error_empty"),"Hình ảnh 3")?></div>";
	if($html_error == ""){
		return true;
	}
	else{
		$('html, body').animate({scrollTop: $(".gio_hang_wp").offset().top}, 0);
		$("#messager").html("<div class='alert alert-error'> <a class='close' data-dismiss='alert'>×</a>"+$html_error+"</div>");
		return false;
	}
});
</script>